note
	description: "Allows to read a file"
	author: "Adrien"
	date: "$Date$"
	revision: "$Revision$"

class
	FILEREADER

create
	make

feature{NONE}
	file_path: STRING;
	input_file : PLAIN_TEXT_FILE;

feature{ANY}
	make(path_to_file: STRING) is
	--make(fichier: STRING) is
		-- Constructor
		require
			path_to_file /= Void
		local
		do
			file_path := path_to_file
			create input_file.make_open_read (path_to_file)
			--pathToFile := fichier
			if not input_file.is_open_read then
				io.put_string ("Unable to open file : " + path_to_file +"%N")
			else
				-- process
				read_file
				input_file.close
			end
		end -- make

	lines_in_file: INTEGER is
	-- The number of lines in filename

		local
			counter: INTEGER
		do
			counter := 0
			from
				input_file.read_line
			until
				input_file.end_of_file
			loop
				input_file.readline
				io.put_string(input_file.last_string + "%N")
				--print (input_file.last_string + "%N")
				counter := counter + 1
			end
			input_file.close
			Result := counter
		end -- lines_in_file

	read_file
		is
			-- Sequential Reading
		local

		do
			from
				input_file.read_line
			until
				input_file.end_of_file
			loop
				input_file.readline
				io.put_string(input_file.last_string + "%N")
				--print (f.last_string + "%N")
			end
			input_file.close
		end -- readFile
end
